package com.yyds.controller;

import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.HospitalDepartment;
import com.yyds.service.HospitalDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/admin/hospital/department")
public class HospitalDepartmentController {

    @Autowired
    @Qualifier("hospitalDepartmentService")
    private HospitalDepartmentService hospitalDepartmentService;

    @RequestMapping("/queryAllDepartment")
    public MyJSON<HospitalDepartment> queryAllHospitalDepartmentController(@RequestParam Map<String,Object> params){

        return hospitalDepartmentService.queryHospitalDepartmentService(params);
    }

    @RequestMapping("/insertDepartment")
    public R insertHospitalDepartmentController(HospitalDepartment hospitalDepartment){

        Integer i = hospitalDepartmentService.insertHospitalDepartmentService(hospitalDepartment);
        return i > 0 ? R.ok() : R.error();
    }

    @RequestMapping("/deleteDepartment")
    public R deleteHospitalDepartmentController(Integer department_id){
        Integer i = hospitalDepartmentService.deleteHospitalDepartmentService(department_id);
        return i > 0 ? R.ok() : R.error();
    }

    @RequestMapping("/updateDepartment")
    public R updateHospitalDepartmentController(HospitalDepartment newHospitalDepartment){
        System.out.println(""+newHospitalDepartment);
        Integer i = hospitalDepartmentService.updateHospitalDepartmentService(newHospitalDepartment);
        return i > 0 ? R.ok() : R.error();
    }
}

